package com.WISSC.config;

import com.WISSC.interceptor.Sessioninterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
 * Created by Zhang on 2018/8/26.
 *
 */
@Configuration
public class SessionConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //配置 不需要拦截的包和请求
   String[]excludePathPatterns=new String[]{
           "/configure/getPhoto",
           "/frame/**",
           "/user/findMenu",
           //用户
           "/user/login.html",
           "/user/login",
           "/user/adminlogin.html",
           "/user/kongbai.html",
           "/user/welcome.html",
           "/user/welcome1.html",
           //学员
           "/student/student_index.html",
           "/student/student_select.html",
           "/student/getManyUrl",
           "/student/Download",
           "/team/getPhoto",
           "/student/certificate.html",
           //资格
           "/occupation/occupation_index.html",
           "/occupation/Download",
           "/occupation/getOccupationUrl",
           "/occupation/coach.html",
           "/occupation/instructor.html",
           "/occupation/referee.html",
           "/occupation/commentator.html",
           "/occupation/evaluation.html",
           //授权机构
           "/authorization/authorization_index.html",
           "/authorization/authorization_select.html",
           "/authorization/authorization_select",
           "/authorization/getPhoto",
           //个人赛事
           "/individualEvent/listIndividualEvent",
           "/individualEvent/selectByIdNumber",
           "/individualEvent/individualEvent_index.html",
           "/individualEvent/individualEvent_select.html",
           "/individualEvent/getPoster",
           "/individualEvent/getPhoto",
           "/individualEvent/listIndividualEvent",
           //战队
           "/team/getPoster",
           "/team/team_index.html",
           "/team/team_select.html",
           "/team/selectTeamName",
           "/team/land",

           "/js/**",
           "/css/**",
           "/image/**",
           "/jquery-1.8.3.min.js",
   };
        registry.addInterceptor(new Sessioninterceptor()).addPathPatterns("/**").excludePathPatterns(excludePathPatterns);
    }


    /* @Override
    public void addViewControllers(ViewControllerRegistry registry){
        registry.addViewController("/").setViewName("user/login.html");
         registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
         super.addViewControllers(registry);
    }*/


}
